package com.xsm.yygh.cmn.listener;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xsm.yygh.cmn.mapper.DictMapper;
import com.xsm.yygh.model.cmn.Dict;
import com.xsm.yygh.vo.cmn.DictEeVo;
import org.springframework.beans.BeanUtils;

/**
 * 数据导入
 */
public class DictListener extends AnalysisEventListener<DictEeVo> {



    DictMapper dictMapper;

    public DictListener(DictMapper dictMapper){
        this.dictMapper = dictMapper;
    }

    /**
     * 逐行扫描
     * @param dictEeVo  dictEeVo = 现在扫到的那行数据
     */
    @Override
    public void invoke(DictEeVo dictEeVo, AnalysisContext analysisContext) {
        Dict dict = new Dict();
        BeanUtils.copyProperties(dictEeVo, dict);
        dictMapper.insert(dict);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {

    }
}
